/*
 * Alloy Analyzer
 * Copyright (c) 2002 Massachusetts Institute of Technology
 *
 * The Alloy Analyzer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Alloy Analyzer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Alloy Analyzer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package alloy.ast;


public class GeneralScope extends TreeNode implements Scope {

    private static final int BOUND_INDEX = 0;

    private static final int BUTSCOPES_INDEX = 1;
    
    public GeneralScope(Location location_, IntNode bound_, TypeScopes butScopes_) {
        super(location_, bound_, butScopes_);
    }


    public GeneralScope(IntNode bound_, TypeScopes butScopes_) {
        super(Location.UNKNOWN, bound_, butScopes_);
    }



    //GET AND SET METHODS

    /**
     * gets the bound of this
     * @return the bound
     */
    public IntNode getBound() {
        return (IntNode)childAt(BOUND_INDEX);
    }

    /** set the Bound of this */
    public void setBound(IntNode newChild_) {
        setChild(BOUND_INDEX, newChild_);
    }

    /**
     * returns a non-negative integer that represents the default scope bound;
     * if this scope does not have a default bound, a negative integer is returned.
     * @return the bound
     */
    public int getDefaultScope() {
	return getBound().getInt();
    }

    /**
     * gets the "but" scopes of this
     */
    public TypeScopes getTypeScopes() {
        return (TypeScopes)childAt(BUTSCOPES_INDEX);
    }

    /** set the ButScopes of this */
    public void setTypeScopes(TypeScopes newChild_) {
        setChild(BUTSCOPES_INDEX, newChild_);
    }

    /**
     * accept an AST visitor
     * @param visitor_ the visitor
     */
    protected void acceptVisitor(ASTVisitor visitor_) {
        visitor_.visit(this);
    }

    /**
     * accept a returning AST visitor
     * @param visitor_ the visitor
     * @return the Object returned by the visitor
     */
    protected Object acceptReturnVisitor(ASTReturnVisitor visitor_) {
        return visitor_.visit(this);
    }

    public String nodeString() {
        String ret = "for " + getBound().nodeString();
        String butScopesString = getTypeScopes().nodeString();
        if (!butScopesString.equals("")) {
            ret = ret + " but " + butScopesString;
        }
        return ret;
    }

    public String toString()
    {
        return nodeString();
    }
}



















